package com.ftg.learn.bus.mapper;

import com.ftg.learn.bus.entity.Approval;
import com.baomidou.mybatisplus.core.mapper.BaseMapper;
import org.apache.ibatis.annotations.Select;
import org.apache.ibatis.annotations.Update;

import java.time.LocalDateTime;
import java.util.List;
import java.util.Map;

/**
 * <p>
 * 审批表 Mapper 接口
 * </p>
 *
 * @author lalala
 * @since 2022-03-07
 */
public interface ApprovalMapper extends BaseMapper<Approval> {

    /**
     * 修改经费支出表内的审核状态
     * @param ex_status
     * @param beid
     * @return
     */
    @Update("update sys_bus_expenditure set examine_status = #{param1},update_time " +
            "= #{param2} where beid = #{param3}")
    boolean updateEx(int ex_status, LocalDateTime updateTime, Long beid);


    /**
     *  查询出所有审批专员的ID。
     * @return
     */
    @Select("select a.uid from sys_user as a left join sys_user_role as b on a.uid = " +
            "b.uid left join sys_role as c on b.rid = c.rid where b.rid = 303")
    List<Map<String,Object>> selectUaid();

    /**
     * 通过此审批人的ID，在人员表内查询此审批人的姓名和联系方式
     * @param uaid
     * @return
     */
    @Select("select uname,uphone from sys_user where uid = #{param1}")
    Map<String,Object> selectAnameAphone(Long uaid);


}
